package com.sky.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;

@Mapper
public interface WorkspaceMapper {

    @Select("select count(id) from user where DATE(create_time) = #{date}")
    Integer getNewUserCount(LocalDate date);

    @Select("select count(id) from orders where DATE(order_time) = #{date}")
    Integer getTotalOrder(LocalDate date);

    @Select("select count(id) from orders where DATE(order_time) = #{date} and status = 5")
    Integer getTotalCompletedOrder(LocalDate date);

    @Select("select sum(amount) from orders where status = 5 and DATE(order_time) = #{date}")
    Double getTurnover(LocalDate date);

    @Select("select count(id) from setmeal where status = 0")
    Integer getSetmealDiscontinued();

    @Select("select count(id) from setmeal where status = 1")
    Integer getSetmealSold();

    @Select("select count(id) from dish where status = 0")
    Integer getDishDiscontinued();

    @Select("select count(id) from dish where status = 1")
    Integer getDishSold();

    @Select("select count(id) from orders where status = 2")
    Integer getWaitingOrders();

    @Select("select count(id) from orders where status = 3")
    Integer getDeliveredOrders();

    @Select("select count(id) from orders where status = 5")
    Integer getCompletedOrders();

    @Select("select count(id) from orders where status = 6")
    Integer getCancelledOrders();

    @Select("select count(id) from orders")
    Integer getAllOrders();
}
